package com.spring.controller;
 
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.spring.datasource.HotelDataSourceFake;
import com.spring.datasource.HotelRESTInfo;
 
/**
 * @author Eggsy - eggsy_at_eggsylife.co.uk
 *
 */
@Controller
public class TourInfoController {
 
	@InitBinder
	public void initBinder(WebDataBinder binder) {
		
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	}
 
//	@RequestMapping(value="/hotel/{hotelId}/dateFrom/{dateFrom}/dateTo/{dateTo}", method=RequestMethod.GET)
//	public ModelAndView showStudentsPage(@PathVariable("hotelId") Long hotelId, @PathVariable("dateFrom") Date dateFrom, @PathVariable("dateTo") Date dateTo) {
		
	@RequestMapping(value="/hotel/{hotelId}", method=RequestMethod.GET)
	public ModelAndView showStudentsPage(@PathVariable("hotelId") Long hotelId) {
	
		// dateFrom and dateTo not used 
		
		HotelDataSourceFake hotelDataSourceFake = new HotelDataSourceFake();
		HotelRESTInfo hotelInfo = hotelDataSourceFake.getFakePlaceById(hotelId);
		
		ModelAndView mav = new ModelAndView("restView");
				
		mav.addObject("hotelInfo", hotelInfo);
		return mav;
	}
}